const { UUIDV4, UUID, STRING, TEXT, JSON, Model } = require('sequelize');
const db = require('../../helpers/db');
const Goods = require('./goods');

class GoodsIntro extends Model {}

GoodsIntro.init(
    {
        id: {
            type: UUID,
            defaultValue: UUIDV4,
            primaryKey: true,
            comment: '商品详情ID'
        },
        imageList: {
            type: STRING(512),
            comment: '商品展示图',
            allowNull: false,
            field: 'image_list'
        },
        detailContent: {
            type: TEXT,
            comment: '商品详情',
            allowNull: false,
            field: 'detail_content'
        },
        sku: {
            type: JSON,
            allowNull: false,
            comment: '商品SKU集合--展示用'
        }
    },
    {
        tableName: 'goods_intro',
        underscored: true,
        sequelize: db
    }
);

GoodsIntro.belongsTo(Goods, {
    foreignKey: 'intro'
});

module.exports = GoodsIntro;
